package com.gds.wiki.cloud.admin.server.modular.sys.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gds.wiki.cloud.admin.client.sys.dto.AdminUserDto;
import com.gds.wiki.cloud.admin.client.sys.model.AdminUser;
import com.gds.wiki.cloud.admin.client.sys.model.query.AdminUserQuery;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/*
* 
* gen by beetlsql mapper 2018-04-23
*/
public interface AdminUserMapper extends BaseMapper<AdminUser> {

    @Select("select a.url,d.name from sys_resource a join sys_role_resource b on a.id=b.resource_id join sys_user_role c on b.role_id=c.role_id " +
            "join sys_role d on d.id=b.role_id where c.user_id=#{uid}")
     List<Map> findUserResourceByUid(@Param("uid") Long uid);

    Page<AdminUserDto> listByDept(Page<AdminUser> page, @Param("userQuery") AdminUserQuery userQuery);

    @Delete("delete from sys_user_role where user_id=#{id}")
    int DelUserRole(@Param("id") Long id);
}
